package com.xiaoyu.lanling.feature.visitor.model

import `in`.srain.cube.request.JsonData
import `in`.srain.cube.views.list.ListItemTypedBase
import com.xiaoyu.base.model.User
import com.xiaoyu.base.utils.extensions.dp
import com.xiaoyu.lanling.feature.user.model.UserExtra
import com.xiaoyu.lanling.media.image.ImageLoadParam
import com.xiaoyu.lanling.media.image.UserImageLoadParam

class VisitorItem constructor(val jsonData: JsonData) : ListItemTypedBase {

    val user = User.fromJson(jsonData.optJson("user"))
    val age = jsonData.optJson("user").optString("age")
    val verified = jsonData.optJson("user").optString("verify") == UserExtra.VerifyStatus.SUCCESS
    val time = jsonData.optString("updateTime")
    val vipIcon = jsonData.optJson("vipInfo").optString("icon")
    val hideVisit = jsonData.optString("hideVisit") == "yes"
    val avatarLoadParams: ImageLoadParam = UserImageLoadParam.newBuilder().setUserAndDP(User.fromJson(jsonData.optJson("user")), 74).build()
    val vipLoadParam: ImageLoadParam = ImageLoadParam.newBuilder().setEnableEmptyUrl(true).setUrl(vipIcon).setSizeInDP(24).build()

    override fun getViewType() = 0
}
